<?php

namespace App\Http\Requests;

use App\Http\Requests\BaseFormRequest;

class MenuRequest extends BaseFormRequest
{
	protected $scene = "store";
	
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function scenes()
    {
        return [
            'store'=>[
				 'name' => 'required|unique:menus|max:255',
				 'route_name' => 'required|max:255',
				 'route_path' => 'required',
				 'component' => 'required',
			],
			'update'=>[
				 'name' => 'required|unique:menus,name,'.$this->input('id').',|max:255',
				 'route_name' => 'required|max:255',
				 'route_path' => 'required',
				 'component' => 'required',
			]
        ];
    }
	
	public function messages()
    {
        return [
			'name.required' => '菜单名称必须',
			'name.unique' => '菜单名称已经存在',
			'name.max' => '菜单名称不能超过255个字符',
			'route_name.required' => '路由名称必须',
			'route_name.max' => '路由名称不能超过255个字符',
			'route_path.required' => '路由路径必须',
			'component.required' => '组件必须',
        ];
    }
}
